Trees | Indices | Toggle frames |
---|
Text formatting, layout and display.
This module provides classes for loading styled documents from text files, HTML files and a pyglet-specific markup format. Documents can be styled with multiple fonts, colours, styles, text sizes, margins, paragraph alignments, and so on.
Using the layout classes, documents can be laid out on a single line or word-wrapped to fit a rectangle. A layout can then be efficiently drawn in a window or updated incrementally (for example, to support interactive text editing).
The label classes provide a simple interface for the common case where an application simply needs to display some text in a window.
A plain text label can be created with:
label = pyglet.text.Label('Hello, world', font_name='Times New Roman', font_size=36, x=10, y=10)
Alternatively, a styled text label using HTML can be created with:
label = pyglet.text.HTMLLabel('<b>Hello</b>, <i>world</i>',
x=10, y=10)
Either label can then be drawn at any time with:
label.draw()
For details on the subset of HTML supported, see pyglet.text.formats.html.
Refer to the Programming Guide for advanced usage of the document and layout classes, including interactive editing, embedding objects within documents and creating scrollable layouts.
Since: pyglet 1.1
pyglet.text.caret Provides keyboard and mouse editing procedures for text layout. | |
pyglet.text.document Formatted and unformatted document interfaces used by text layout. | |
pyglet.text.formats Document formats. | |
pyglet.text.formats.attributed Extensible attributed text format for representing pyglet formatted
documents. | |
pyglet.text.formats.html Decode HTML into attributed text. | |
pyglet.text.formats.plaintext Plain text decoder. | |
pyglet.text.formats.structured Base class for structured (hierarchical) document formats. | |
pyglet.text.layout Render simple text and formatted documents efficiently. | |
pyglet.text.runlist Run list encoding utilities. |
DocumentDecodeException
An error occurred decoding document text.
|
|
DocumentDecoder
Abstract document decoder.
|
|
DocumentLabel
Base label class.
|
|
Label
Plain text label.
|
|
HTMLLabel
HTML formatted text label.
|
DocumentDecoder |
get_decoder(filename,
mimetype=None)
Get a document decoder for the given filename and MIME type.
|
AbstractDocument |
load(filename,
file=None,
mimetype=None)
Load a document from a file.
|
FormattedDocument |
decode_html(text,
location=None)
Create a document directly from some HTML formatted text.
|
FormattedDocument |
decode_attributed(text)
Create a document directly from some attributed text.
|
UnformattedDocument |
decode_text(text)
Create a document directly from some plain text.
|
__package__ =
|
Get a document decoder for the given filename and MIME type.
If mimetype
is omitted it is guessed from the filename extension.
The following MIME types are supported:
DocumentDecodeException is raised if another MIME type is given.
filename
is
loaded from disk.Create a document directly from some attributed text.
See pyglet.text.formats.attributed for a description of attributed text.
Trees | Indices | Toggle frames |
---|
Generated by Epydoc 3.0beta1 on Thu Dec 31 17:58:18 2009 | http://epydoc.sourceforge.net |